﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;

namespace Inspired.Euler
{
    public static class Problem048
    {
        static void Main()
        {
            //var x = Enumerable.Range(1, 1000).Aggregate(0D, (seed, n) => seed += Math.Pow(n, n) % (Math.Pow(10, 10) + 1));

            BigInteger result = BigInteger.Zero;
            for (int n = 1; n <= 1000; n++)
            {
                result = BigInteger.Add(result, BigInteger.Pow(n, n));
            }
            (result % BigInteger.Pow(10, 10)).DisplayAndPause(); // 10405071317
        }
    }
}
